<template>
  <view>
    <view :style="'--color:' + color + ';--rgbcolor:' + rgbcolor" class="topbar">
      <text v-for="(item, index) in topbar" :key="index" :class="'item ' + (currentTab == index ? 'active' : '')"
            :data-idx="index" @tap="topbarFn">{{ item }}
      </text>
    </view>
    <block v-if="currentTab == 0">
      <view v-if="LIST1.length > 0" class="my_browse">
        <view v-if="blurU.class == 'blur'" class="viptips" @tap="vipFn">
          <view class="ivubox">
            <view v-for="(item, index) in blurU.list" :key="index" class="span">
              <image :src="item" mode="aspectFill"></image>
            </view>
          </view>
          <view class="font">
            最近有
            <text class="b">{{ blurU.num }}</text>
            人看过你
          </view>
          <view class="h5">缘分就在一瞬间，不错过喜欢你的人</view>
          <view :style="'--color:' + color + ';--rgbcolor:' + rgbcolor" class="btn4">
            　
            <text class="i ico"></text>
            立即开通VIP查看　
          </view>
        </view>
        <block v-else>
          <block v-for="(dl, idx_list) in LIST1" :key="idx_list">
            <view v-for="(item, idx_dl) in dl" v-if="item != null" :key="idx_dl" :data-uid="item.uid" class="dl">
              <view :data-uid="item.uid" class="dt" @tap="uidFn">
                <image :src="item.photo_s" mode="aspectFill"></image>
              </view>

              <view class="dd">
                <view class="h4">
                  <image :src="item.grade_ico" class="ugrade1"></image>
                  {{ item.nickname }}
                </view>
                <view class="h6">
                  <block v-for="(D, Didx) in item.data" :key="Didx">
                    {{ D }}

                    <text v-if="Didx + 1 != item.data.length" class="b">/</text>
                  </block>
                </view>
              </view>

              <view class="span">{{ item.addtime }}</view>
            </view>
          </block>
        </block>
      </view>
      <view v-if="nodatabox1" class="nodata">
        <image mode="aspectFit" src="/static/res/img/nodata.png"></image>
        暂无信息
      </view>
    </block>
    <block v-if="currentTab == 1">
      <view v-if="LIST2.length > 0" class="my_browse">
        <block v-for="(dl, idx_list) in LIST2" :key="idx_list">
          <view v-for="(item, idx_dl) in dl" :key="idx_dl" :data-uid="item.uid" class="dl">
            <view :data-uid="item.uid" class="dt" @tap="uidFn">
              <image :src="item.photo_s" mode="aspectFill"></image>
            </view>

            <view class="dd">
              <view class="h4">
                <image :src="item.grade_ico" class="ugrade1"></image>
                {{ item.nickname }}
              </view>
              <view class="h6">
                <block v-for="(D, Didx) in item.data" :key="Didx">
                  {{ D }}

                  <text v-if="Didx + 1 != item.data.length" class="b">/</text>
                </block>
              </view>
            </view>

            <view class="span">{{ item.addtime }}</view>
          </view>
        </block>
      </view>
      <view v-if="nodatabox2" class="nodata">
        <image mode="aspectFit" src="/static/res/img/nodata.png"></image>
        暂无信息
      </view>
    </block>
    <view v-if="loading_flag" class="loading">
      <image v-if="loading_ico_flag" class="loading_ico" src="/static/res/img/loading_ico.svg"></image>
      <text>{{ loading_str }}</text>
    </view>
    <view class="blank"></view>
  </view>
</template>

<script>
var a = require('../../@babel/runtime/helpers/defineProperty');
var t = require('../../res/www.a9a.cn.js');
var app = getApp();
var i = 2;
var n = true;
var o = uni.getStorageSync('COOK_U');
export default {
  data() {
    return {
      topbar: ['谁看过我', '我看过谁'],
      currentTab: 0,
      loading_flag: false,
      loading_ico_flag: false,
      loading_str: '拼命加载中',
      color: '',
      rgbcolor: '',

      blurU: {
        class: '',
        list: [],
        num: ''
      },

      LIST1: [],
      idx_list: [],
      dl: [],
      idx_dl: 0,
      Didx: 0,
      nodatabox1: '',
      LIST2: [],
      nodatabox2: ''
    };
  },
  onLoad: function (a) {
    var o = a.t;
    var r = 1 == o ? this.topbar[0] : this.topbar[1];
    uni.setNavigationBarTitle({
      title: r
    });
    var that = this;
    app.globalData.get_config('_ZEAI').then(function (a) {
      that.setData({
        color: a.color,
        rgbcolor: t.c16_rgb(a.color),
        currentTab: o - 1
      });
      i = 2;
      n = true;
      that.get_data(o);
    });
  },
  onReachBottom: function () {
    var that = this;
    var r = parseInt(this.currentTab) + 1;
    switch (r) {
      case 1:
        var s = this.LIST1;
        break;
      case 2:
        s = this.LIST2;
    }
    o = uni.getStorageSync('COOK_U');
    if (n) {
      n = false;
      that.setData({
        loading_ico_flag: true
      });
      app.globalData.ajax({
        url: 'my_browse.php',
        data: {
          submitok: 'list',
          t: r,
          p: i,
          openid: o.openid
        },
        success: function (e) {
          switch (r) {
            case 1:
              var o = e.LIST1;
              break;
            case 2:
              o = e.LIST2;
          }
          if (o.length < 1) {
            that.setData({
              loading_flag: true,
              loading_ico_flag: false,
              loading_str: '已全部加载完成'
            });
            return void (n = false);
          }
          that.setData(a({}, 'LIST' + r + '[' + s.length + ']', o));
          i += 1;
          n = true;
        }
      });
    }
  },
  methods: {
    topbarFn: function (a) {
      var t = parseInt(a.currentTarget.dataset.idx);
      this.setData({
        currentTab: t
      });
      this.get_data(t + 1);
      uni.setNavigationBarTitle({
        title: this.topbar[t]
      });
    },

    get_data: function (t) {
      var that = this;
      t = parseInt(t);
      app.globalData.chklogin().then(function (a) {
        a || uni.navigateBack();
      });
      n = false;
      o = uni.getStorageSync('COOK_U');
      app.globalData.ajax({
        url: 'my_browse.php',
        data: {
          submitok: 'list',
          t: t,
          openid: o.openid
        },
        success: function (e) {
          switch (t) {
            case 1:
              var o = e.LIST1;
              break;
            case 2:
              o = e.LIST2;
          }
          if (1 == e.flag) {
            var r;
            that.setData({
              blurU: e.blurU
            });
            if (o.length >= 15) {
              that.setData({
                loading_flag: true,
                loading_ico_flag: true
              });
            }
            if (0 == o.length) {
              that.setData(
                  a(
                      {
                        loading_flag: false
                      },
                      'nodatabox' + t,
                      true
                  )
              );
            } else {
              that.setData((a((r = {}), 'LIST' + t + '[0]', o), a(r, 'nodatabox' + t, false), a(r, 'loading_flag', false), r));
            }
            n = true;
          } else {
            uni.showModal({
              content: e.msg,
              confirmColor: that.color,
              confirmText: '朕知道了',
              showCancel: false,
              success: function (a) {
                uni.navigateBack();
              }
            });
          }
        }
      });
    },

    uidFn: function (a) {
      var t = a.currentTarget.dataset.uid;
      uni.navigateTo({
        url: '/pagesA/u/u?uid=' + t
      });
    },

    vipFn: function () {
      uni.navigateTo({
        url: '/pagesA/my_vip/my_vip'
      });
    }
  }
};
</script>
<style>
@import 'browse.css';
</style>
